Enter bob private key (XB < q):

Enter Alice private key (XA < q):











Diffie-Hellman key exchange is a fundamental algorithm for secure cryptographic key sharing. It capitalizes on the complexity of discrete logarithms, making it impractical for attackers to deduce shared secret keys. Users generate private and public keys, exchange public keys, and compute a shared secret key, ensuring robust security in various cryptographic applications.

Diffie-Hellman Key Exchange Example

In this example of the Diffie-Hellman key exchange:

  • Both Alice and Bob share a prime number q = 353 and a primitive root α = 3.
  • Alice selects a private key XA = 97 and computes her public key YA = 397 mod 353, resulting in YA = 40.
  • Bob selects a private key XB = 233 and computes his public key YB = 3233 mod 353, resulting in YB = 248.
  • After exchanging public keys, both Alice and Bob independently compute a shared secret key using the received public key and their own private key:
    • Alice calculates K = (YB)XA mod 353, resulting in K = 160.
    • Bob calculates K = (YA)XB mod 353, also resulting in K = 160.